<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('角色添加')" />
</head>
<body>
	<section class="content">
		<form class="form-horizontal" id="roleForm">
           <div class="box-body">
               <div class="form-group">
                   <label for="name" class="col-sm-3 control-label">角色名称 :</label>
                   <div class="col-sm-8">
                       <input type="text" class="form-control" name="name" id="name" required placeholder="输入角色名称">
                   </div>
               </div>
               <div class="form-group">
                   <label for="description" class="col-sm-3 control-label">角色描述 :</label>
                   <div class="col-sm-8">
                       <input type="text" class="form-control" name="description" id="description" required placeholder="输入角色描述">
                   </div>
               </div>
           </div>
       </form>
	</section>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		function submitHandler() {
			if($("#roleForm").validate().form()){
                $.common.postAjax(
                    ctx + "role/doAdd",
                    $("#roleForm").serialize(),
                    function (data) {
                        if(data.code == 0){
                            parent.layer.closeAll('iframe'); // 关闭当前frame
                            var topWindow = $(window.parent.document);
                            var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
                            var topWindow = $('.J_iframe[data-id="' + currentId + '"]', topWindow)[0];
                            if (!$.common.isEmpty(topWindow) && !$.common.isEmpty(currentId)) {
                                var $contentWindow = topWindow.contentWindow;
                                $contentWindow.$(".layui-layer-padding").removeAttr("style");
                                $contentWindow.$.table.refreshTable();
                                $contentWindow.toastr.success(data.msg);
                            } else {
                                toastr.error(data.msg);
                            }
                        } else {
                            toastr.error(data.msg);
                        }
                    }
                )
            }
		}
	</script>
</body>
</html>